import logo from '@/assets/images/logo.png'
import defaultSettings from '@/settings'

const { title, fixedHeader, sidebarLogo, defaultOpeneds } = defaultSettings

const state = {
  title: title,
  logo,
  fixedHeader: fixedHeader,
  sidebarLogo: sidebarLogo,
  defaultOpeneds: defaultOpeneds,
}

const getters = {
  title: (state) => state.title,
  logo: (state) => state.logo,
  fixedHeader: (state) => state.fixedHeader,
  sidebarLogo: (state) => state.sidebarLogo,
  defaultOpeneds: (state) => state.defaultOpeneds,
}

const mutations = {
  CHANGE_SETTING: (state, { key, value }) => {
    if (Object.prototype.hasOwnProperty.apply(state, key)) {
      state[key] = value
    }
  },
}

const actions = {
  changeSetting({ commit }, data) {
    commit('CHANGE_SETTING', data)
  },
}

export default {
  namespaced: true,
  getters,
  state,
  mutations,
  actions,
}
